from unittest.case import TestCase

import requests

# Create your tests here.

class ApproveTest(TestCase):
    base_url = 'http://127.0.0.1:8000'

    def full_url(self, path):
        return self.base_url + path

    def test_approve_add(self):
        url = self.full_url('/approve/')
        data = {
            'staff': '45f0a1f90df148e3a2693a5494db95a9',
            'content': '西安白凤酒业营销有限公司下单西风六年一千件',
            'kind': '出库',
            'approvers': ['5ebd73384223472997a48dd65699012d', '0e8f8a9eb00d48848e8e5dd75d89968d']
        }
        resp = requests.post(url,json=data)
        print(resp.text)

    def test_approve_update(self):
        url = self.full_url('/approve/')
        data = {
            'staff': '0e8f8a9eb00d48848e8e5dd75d89968d',
            'approve': 'db9da62ae39c4e398231992a24028ebc',
            'idea': '同意',
            'content': '发货，确保在规定区域内销售'
        }
        resp = requests.put(url,json=data)
        print(resp.text)

    def test_get_approve(self):
        url = self.full_url('/approve/?staff=45f0a1f90df148e3a2693a5494db95a9')
        resp = requests.get(url)
        print(resp.text)

    def test_get_apprflow(self):
        url = self.full_url('/approve/flow/8c7a5e4d84ad47598258e893f962c492/')
        resp = requests.get(url)
        print(resp.text)

    def test_bills_add(self):
        url = self.full_url('/bills/')
        data = {
            'num': 'A000000002',
            'ware': 'c4f935f1d3674c72851dd6884747988f',
            'count': 100,
            'goods':'62a2270c29244ec9a9107156bca508a1',
            'company':'西安宏达酒业有限公司',
            'signer':'李富贵',
            'address':'陕西省西安市科技四路南窑头社区西区',
            'indent':'4504f4b7409e4bc883b2d13c2cef1d64'
        }
        resp = requests.post(url,json=data)
        print(resp.text)

    def test_get_bills(self):
        url = self.full_url('/bills/?staff=0e8f8a9eb00d48848e8e5dd75d89968d')
        resp = requests.get(url)
        print(resp.text)


    def test_add_indent(self):
        url = self.full_url('/order/')
        data = {
            'goods': 'b84ed381640347a490aeea1125aa8432',
            'num': '1000',
            'sign_name': '王铁锤',
            'phone':'14568787157',
            'company':'宝鸡朱雀酒业营销有限公司',
            'type':'订货',
            'content':'第三季度货品',
            'kind':'出库',
            'approvers':['5ebd73384223472997a48dd65699012d', '0e8f8a9eb00d48848e8e5dd75d89968d'],
            'address':'陕西省宝鸡市陈仓区虢镇东门东大街派出所向东100米'
        }
        resp = requests.post(url,json=data)
        print(resp.text)

    def test_update_indent(self):
        url = self.full_url('/order/')
        data = {
            'indent':'4504f4b7409e4bc883b2d13c2cef1d64',
            'indent_status':'完成',
            'pay_status':'已支付'
        }
        resp = requests.put(url,json=data)
        print(resp.text)

    def test_get_indent(self):
        url = self.full_url('/order/?staff=0e8f8a9eb00d48848e8e5dd75d89968d')
        resp = requests.get(url)
        print(resp.text)

    def test_get_indenthis(self):
        url = self.full_url('/order/history/?staff=0e8f8a9eb00d48848e8e5dd75d89968d')
        resp = requests.get(url)
        print(resp.text)


    def test_get_inform(self):
        url = self.full_url('/inform/?staff=45f0a1f90df148e3a2693a5494db95a9')
        resp = requests.get(url)
        print(resp.text)

    def test_get_informdetail(self):
        url = self.full_url('/inform/6e59aa7c0f424e699617e3ddba9bdb1d/')
        resp = requests.get(url)
        print(resp.text)